#index-book
  .header
    %span.title= t('.book_list')
    - if current_user.admin?
      %span.create_btn.btn= link_to t('.new_book'), new_book_path

  %table#books-list.table-striped
    %tr.heading
      %th= t('.cover')
      %th= sortable(book_path_proc, :isbn, t('.isbn'))
      %th= sortable(book_path_proc, :name, t('.name'))
      %th= sortable(book_path_proc, :category_id, t('.category'))
      %th= sortable(book_path_proc, :author, t('.author'))
      %th= sortable(book_path_proc, :description, t('.description'))
      - if current_user.admin?
        %th
    - @books.each do |book|
      %tr
        %td.cover= image_tag book.image_url(:thumb) if book.image?
        %td.isbn= book.isbn
        %td.name= link_to book.name, book
        %td.category= book.category.try(:name)
        %td.author= book.author
        %td.description= simple_format(truncate(book.description, length: 80))
        - if current_user.admin?
          %td.action
            = link_to t('.edit'), edit_book_path(book)
            = '|'
            = link_to t('.destroy'), book, method: :delete, data: { confirm: t('.confirm') }
  %p= will_paginate @books, renderer: BootstrapPagination::Rails

